package com.itheima.ydd.common;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Y<T> {

    private Integer errno; //编码：1成功，0和其它数字为失败

    private String errmsg; //错误信息

    private T data; //数据

    private Map map = new HashMap(); //动态数据

    public static <T> Y<T> success(T object) {
        Y<T> y = new Y<T>();
        y.data = object;
        y.errno = 0;
        y.errmsg = "";
        return y;
    }

    public static <T> Y<T> error(String msg) {
        Y r = new Y();
        r.errmsg = msg;
        r.errno = 1000;
        return r;
    }
}
